package com.ygp.asyn.util;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LogUtil {
    public static void info(Object pre, Object url, Object head, Object param, Object res) {
        if (!(res instanceof String)) {
            res = JSON.toJSONString(res);
        }
        if (!(head instanceof String)) {
            head = JSON.toJSONString(head);
        }
        if (!(param instanceof String)) {
            param = JSON.toJSONString(param);
        }
        log.info("LogUtil PRE: " + pre + " URL:{} HEAD:{} PARAM:{} RES:{}", url, head, param, res);
    }

    public static void error(Object pre, Object url, Object head, Object param, Exception e) {
        if (!(head instanceof String)) {
            head = JSON.toJSONString(head);
        }
        if (!(param instanceof String)) {
            param = JSON.toJSONString(param);
        }
        log.error("LogUtil PRE: " + pre + " URL:{} HEAD:{} PARAM:{} error: ", url, head, param, e);
    }

}
